import { Body, Controller, Get, Post, Res, Session } from "@nestjs/common"
import { AuthorizationService } from "./authorization.service"
import { Response } from "express"

@Controller("authorization")
export class AuthorizationController {
  constructor(private readonly authorizationService: AuthorizationService) {}

  // Obtain all authorization information
  @Get("/getAll")
  async getAll(
    @Res() res: Response,
    @Session() session: object
  ): Promise<void> {
    return await this.authorizationService.getAll(res, session)
  }

  // Obtain all authorization information with soft deletion
  @Get("/getAllWithDeleted")
  async getAllWithDeleted(@Res() res: object): Promise<void> {
    return await this.authorizationService.getAllWithDeleted(res)
  }

  // Fuzzy search authorization information
  @Post("/search")
  async search(
    @Body() body: object,
    @Res() res: Response,
    @Session() session: object
  ): Promise<void> {
    return this.authorizationService.search(body, res, session)
  }

  // Fuzzy search authorization information with soft deletion
  @Post("/searchWithDeleted")
  async searchWithDeleted(
    @Body() body: object,
    @Res() res: object
  ): Promise<void> {
    return this.authorizationService.searchWithDeleted(body, res)
  }

  // Add authorization information
  @Post("/add")
  async add(@Body() body: object, @Res() res: object): Promise<void> {
    return await this.authorizationService.add(body, res)
  }

  // Update authorization information
  @Post("/update")
  async update(@Body() body: object, @Res() res: object): Promise<void> {
    return await this.authorizationService.update(body, res)
  }

  // Soft deletion authorization information
  @Post("/delete")
  async delete(@Body() body: object, @Res() res: object): Promise<void> {
    return await this.authorizationService.delete(body, res)
  }

  // Real deletion authorization information
  @Post("/remove")
  async remove(@Body() body: object, @Res() res: object): Promise<void> {
    return await this.authorizationService.remove(body, res)
  }

  // Batch soft deletion of authorization information
  @Post("/deleteGroup")
  async deleteGroup(@Body() body: object, @Res() res: object): Promise<void> {
    return await this.authorizationService.deleteGroup(body, res)
  }

  // Batch real deletion of authorization information
  @Post("/removeGroup")
  async removeGroup(@Body() body: object, @Res() res: object): Promise<void> {
    return await this.authorizationService.removeGroup(body, res)
  }

  // Restore authorization information
  @Post("/restore")
  async restore(@Body() body: object, @Res() res: object): Promise<void> {
    return await this.authorizationService.restore(body, res)
  }

  // Check if authorization is granted
  @Post("/check")
  async check(@Body() body: object, @Res() res: object): Promise<void> {
    return await this.authorizationService.check(body, res)
  }

  // Obtain the number of genuine authorization
  @Get("/count")
  async count(@Res() res: object): Promise<void> {
    await this.authorizationService.count(res)
  }
}
